package com.xjh.t.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xjh.t.common.Constast;
import com.xjh.t.common.DataGridView;
import com.xjh.t.domain.AreaInfo;
import com.xjh.t.service.IAreaInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jobob
 * @since 2020-03-12
 */
@RestController
@RequestMapping("/areaInfo")
public class AreaInfoController {

    @Autowired
    private IAreaInfoService areaInfoService;

    @RequestMapping("loadAllProvince")
    public List<AreaInfo> loadAllProvince()
    {
        QueryWrapper<AreaInfo> areaInfoQueryWrapper = new QueryWrapper<>();
        areaInfoQueryWrapper.eq("aa_level", Constast.POLICY_TOP_LEVEL);
        List<AreaInfo> areaInfos = this.areaInfoService.list(areaInfoQueryWrapper);

        return areaInfos;
    }
    @RequestMapping("loadChildArea")
    public List<AreaInfo> loadChildArea(Integer areaId)
    {
        QueryWrapper<AreaInfo> areaInfoQueryWrapper = new QueryWrapper<>();
        areaInfoQueryWrapper.eq("aa_parentid", areaId);
        List<AreaInfo> areaInfos = this.areaInfoService.list(areaInfoQueryWrapper);

        return areaInfos;
    }

}

